package com.ruoyi.control.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.control.domain.Mainventilator1History;
import com.ruoyi.control.domain.MainventilatorOne;
import com.ruoyi.control.domain.MainventilatorTwo;
import com.ruoyi.control.mapper.GasDrainagePumpRoomMapper;
import com.ruoyi.control.mapper.MainventilatorOneMapper;
import com.ruoyi.control.mapper.MainventilatorTwoMapper;
import com.ruoyi.kepServer.aircompressor.mapper.AircompressorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.control.mapper.GasDrainagePumpRoomHistoryMapper;
import com.ruoyi.control.domain.GasDrainagePumpRoomHistory;
import com.ruoyi.control.service.IGasDrainagePumpRoomHistoryService;

/**
 * 瓦斯抽放泵房Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-08
 */
@Service
public class GasDrainagePumpRoomHistoryServiceImpl extends ServiceImpl<GasDrainagePumpRoomHistoryMapper, GasDrainagePumpRoomHistory> implements IGasDrainagePumpRoomHistoryService //修改
{
    @Autowired
    private GasDrainagePumpRoomHistoryMapper gasDrainagePumpRoomHistoryMapper;
    @Autowired
    private MainventilatorTwoMapper mainventilatorTwoMapper;
    @Autowired
    private MainventilatorOneMapper mainventilatorOneMapper;
    @Autowired
    private GasDrainagePumpRoomMapper gasDrainagePumpRoomMapper;
    @Autowired
    private AircompressorMapper aircompressorMapper;
    /**
     * 查询瓦斯抽放泵房
     *
     * @param id 瓦斯抽放泵房主键
     * @return 瓦斯抽放泵房
     */
    @Override
    public GasDrainagePumpRoomHistory selectGasDrainagePumpRoomHistoryById(String id)
    {
        return gasDrainagePumpRoomHistoryMapper.selectGasDrainagePumpRoomHistoryById(id);
    }

    /**
     * 查询瓦斯抽放泵房列表
     *
     * @param gasDrainagePumpRoomHistory 瓦斯抽放泵房
     * @return 瓦斯抽放泵房
     */
    @Override
    public List<GasDrainagePumpRoomHistory> selectGasDrainagePumpRoomHistoryList(GasDrainagePumpRoomHistory gasDrainagePumpRoomHistory)
    {
        return gasDrainagePumpRoomHistoryMapper.selectGasDrainagePumpRoomHistoryList(gasDrainagePumpRoomHistory);
    }

    /**
     * 新增瓦斯抽放泵房
     *
     * @param gasDrainagePumpRoomHistory 瓦斯抽放泵房
     * @return 结果
     */
    @Override
    public int insertGasDrainagePumpRoomHistory(GasDrainagePumpRoomHistory gasDrainagePumpRoomHistory)
    {
        return gasDrainagePumpRoomHistoryMapper.insertGasDrainagePumpRoomHistory(gasDrainagePumpRoomHistory);
    }

    /**
     * 修改瓦斯抽放泵房
     *
     * @param gasDrainagePumpRoomHistory 瓦斯抽放泵房
     * @return 结果
     */
    @Override
    public int updateGasDrainagePumpRoomHistory(GasDrainagePumpRoomHistory gasDrainagePumpRoomHistory)
    {
        gasDrainagePumpRoomHistory.setUpdateTime(DateUtils.getNowDate());
        return gasDrainagePumpRoomHistoryMapper.updateGasDrainagePumpRoomHistory(gasDrainagePumpRoomHistory);
    }

    /**
     * 批量删除瓦斯抽放泵房
     *
     * @param ids 需要删除的瓦斯抽放泵房主键
     * @return 结果
     */
    @Override
    public int deleteGasDrainagePumpRoomHistoryByIds(String[] ids)
    {
        return gasDrainagePumpRoomHistoryMapper.deleteGasDrainagePumpRoomHistoryByIds(ids);
    }

    /**
     * 删除瓦斯抽放泵房信息
     *
     * @param id 瓦斯抽放泵房主键
     * @return 结果
     */
    @Override
    public int deleteGasDrainagePumpRoomHistoryById(String id)
    {
        return gasDrainagePumpRoomHistoryMapper.deleteGasDrainagePumpRoomHistoryById(id);
    }

    @Override
    public Integer[] selectByTagName(String tagName) {
        Integer[] history= new Integer[60*24];
        List<GasDrainagePumpRoomHistory> historyList=gasDrainagePumpRoomHistoryMapper.selectByTagName(tagName);
        for (int i=0; i<60*24;i++){
            if (i>=historyList.size()){
                history[i]= 0;
            }else {
                double doubleValue = Double.parseDouble(historyList.get(i).getValue());
                int intValue = (int) doubleValue; // 如果需要四舍五入，可以使用 Math.round(doubleValue)
                history[i] = intValue;
            }
        }
        return history;
    }

    @Override
    public String[] getRealNum() {
        String[]  arr=new String[13];

        arr[0]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump1_xiaolv").getValue());
        arr[1]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump2_xiaolv").getValue());
        arr[2]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump5_xiaolv").getValue());
        arr[3]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump6_xiaolv").getValue());
        arr[4]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump7_xiaolv").getValue());
        arr[5]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump8_xiaolv").getValue());
        arr[6]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump9_xiaolv").getValue());
        arr[7]= String.valueOf(gasDrainagePumpRoomMapper.selectGasDrainagePumpRoomByTagName("ws_pump10_xiaolv").getValue());
        arr[8]= String.valueOf(mainventilatorOneMapper.selectMainventilatorOneByName("zs_fengji1_xiaolv").getValue());
        arr[9]= String.valueOf(mainventilatorOneMapper.selectMainventilatorOneByName("zs_fengji2_xiaolv").getValue());
        arr[10]= String.valueOf(aircompressorMapper.selectAircompressorByTagName("1#空压机效率").getValue());
        arr[11]= String.valueOf(aircompressorMapper.selectAircompressorByTagName("2#空压机效率").getValue());
        arr[12]= String.valueOf(aircompressorMapper.selectAircompressorByTagName("3#空压机效率").getValue());
        return arr;
    }

}
